package ProjectYudisium;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class TableModelYudisium extends AbstractTableModel {

    private String coloumNames[] = {"NIM", "Nama", "NoHP", "PeriodeYudisium", "Prodi", "Fakultas"};
    private ArrayList<Yudisium> data;

    public TableModelYudisium() {
    }

    public TableModelYudisium(ArrayList<Yudisium> data) {
        this.data = data;
    }

    @Override
    public int getRowCount() {
        return getData().size();
    }

    @Override
    public int getColumnCount() {
        return coloumNames.length;
    }

    public String getColoumNames(int kolom) {
        return coloumNames[kolom];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Yudisium temp = getData().get(rowIndex);
        if (columnIndex == 0) {
            return temp.getNim();
        } else if (columnIndex == 1) {
            return temp.getNama();
        } else if (columnIndex == 2) {
            return temp.getNoHP();
        } else if (columnIndex == 3) {
            return temp.getPeriodeYudisium();
        } else if (columnIndex == 4) {
            return temp.getProdi();
        } else {
            return temp.getFakultas();
        }
    }

    public ArrayList<Yudisium> getData() {
        return data;
    }

    public void setData(ArrayList<Yudisium> data) {
        this.data = data;
    }
}
